<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/27/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/27/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/03/04/%E5%88%86%E6%95%A3%E5%8A%A0%E8%BD%BD%E6%96%87%E4%BB%B6%E5%88%86%E9%85%8D%E5%8F%98%E9%87%8F%E5%88%B0%E5%A4%96%E9%83%A8SDRAM/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/03/04/%E5%88%86%E6%95%A3%E5%8A%A0%E8%BD%BD%E6%96%87%E4%BB%B6%E5%88%86%E9%85%8D%E5%8F%98%E9%87%8F%E5%88%B0%E5%A4%96%E9%83%A8SDRAM/" class="post-title-link" itemprop="url">分散加载文件分配变量到外部SDRAM</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-03-04 10:27:30" itemprop="dateCreated datePublished" datetime="2021-03-04T10:27:30+08:00">2021-03-04</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/03/04/%E5%88%86%E6%95%A3%E5%8A%A0%E8%BD%BD%E6%96%87%E4%BB%B6%E5%88%86%E9%85%8D%E5%8F%98%E9%87%8F%E5%88%B0%E5%A4%96%E9%83%A8SDRAM/" class="post-meta-item leancloud_visitors" data-flag-title="分散加载文件分配变量到外部SDRAM" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/03/04/%E5%88%86%E6%95%A3%E5%8A%A0%E8%BD%BD%E6%96%87%E4%BB%B6%E5%88%86%E9%85%8D%E5%8F%98%E9%87%8F%E5%88%B0%E5%A4%96%E9%83%A8SDRAM/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/03/04/%E5%88%86%E6%95%A3%E5%8A%A0%E8%BD%BD%E6%96%87%E4%BB%B6%E5%88%86%E9%85%8D%E5%8F%98%E9%87%8F%E5%88%B0%E5%A4%96%E9%83%A8SDRAM/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="1-访问SDRAM存储器"><a href="#1-访问SDRAM存储器" class="headerlink" title="1. 访问SDRAM存储器"></a>1. 访问SDRAM存储器</h2><p>​    在stm32上初始化SDRAM之后，就可用它来存储数据。SDRAM的存储空间是被映射到内核的寻址区域的，可以通过映射的地址直接访问 SDRAM。访问这些地址时，FMC 外设自动读写 SDRAM，程序上无需额外操作。</p>
<h3 id="1-1-使用指针访问"><a href="#1-1-使用指针访问" class="headerlink" title="1.1 使用指针访问"></a>1.1 使用指针访问</h3><p>​    通过地址访问内存，最直接的方式就是使用 C 语言的指针，如下图代码所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">define</span> SDRAM_BANK_ADDR ((uint32_t)0X68000000)</span></span><br><span class="line"><span class="comment">/*写16位数据*/</span></span><br><span class="line">*( <span class="keyword">uint16_t</span>*) (SDRAM_BANK_ADDR) = (<span class="keyword">uint16_t</span>)<span class="number">0x1234</span>;</span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210225203633.png" style="zoom:67%;">

<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*写32位数据*/</span></span><br><span class="line">*( <span class="keyword">uint32_t</span>*) (SDRAM_BANK_ADDR) = (<span class="keyword">uint32_t</span>)<span class="number">0x12345678</span>;</span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210225204134.png" style="zoom:67%;">

<h3 id="1-2-直接指定变量存储到SDRAM空间"><a href="#1-2-直接指定变量存储到SDRAM空间" class="headerlink" title="1.2 直接指定变量存储到SDRAM空间"></a>1.2 直接指定变量存储到SDRAM空间</h3><p>​    每次存取数据都使用指针来访问太麻烦了，为了简化操作，可以直接指定变量存储到SDRAM 空间。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*绝对定位方式访问 SDRAM,这种方式必须定义成全局变量*/</span></span><br><span class="line"><span class="keyword">uint16_t</span> testValue __attribute__((at(SDRAM_BANK_ADDR)));</span><br><span class="line">testValue = <span class="number">0x5678</span>;</span><br></pre></td></tr></table></figure>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210225205850.png" style="zoom:67%;">

<p>​    这种方式使用关键字“<strong>attribute</strong>((at()))”来指定变量的地址，代码中指定 testValue存储到SDRAM的起始地址，从而实现把变量存储到SDRAM上。更常见的是利用这种方法定义一个很大的数组，整个数组都指定到SDRAM地址上，然后就像使用malloc 函数一样，用户自定义一些内存管理函数，动态地使用 SDRAM 的内存。</p>
<h2 id="2-修改分散加载文件分配变量到外部SDRAM空间"><a href="#2-修改分散加载文件分配变量到外部SDRAM空间" class="headerlink" title="2. 修改分散加载文件分配变量到外部SDRAM空间"></a>2. 修改分散加载文件分配变量到外部SDRAM空间</h2><p>​    这边的实验以及一些资料都来源于野火，在这表示感谢。上面我们使用指针或者<strong>attribute</strong>((at(具体地址)))来指定变量的位置，当有多个这样的变量时，就需要手动计算地址空间了，非常麻烦。所以我们将修改 sct 文件，让链接器自动分配全局变量到 SDRAM 的地址并进行管理，使得利用 SDRAM 的空间就跟内部 SRAM 一样简单。</p>
<h3 id="2-1-修改启动文件，在-main-执行之前初始化-SDRAM"><a href="#2-1-修改启动文件，在-main-执行之前初始化-SDRAM" class="headerlink" title="2.1 修改启动文件，在__main 执行之前初始化 SDRAM"></a>2.1 修改启动文件，在__main 执行之前初始化 SDRAM</h3><p>​    芯片启动后，会通过<strong>_main 函数调用分散加载代码 _scatterload</strong>，分散加载代码会把存储在 FLASH 中的 RW-data 复制到 RAM中，然后在 RAM 区开辟一块 ZI-data 的空间，并将其初始化为 0 值。因此，为了保证在程</p>
<p>序中定义到 SDRAM 中的变量能被正常初始化，我们需要在系统执行分散加载代码之前使SDRAM 存储器正常运转，使它能够正常保存数据。</p>
<p>​    我们以前会使用 FSMC_SRAM_Init函数初始化 SDRAM，且该函数在 main 函数里才被调用，所以在 SDRAM 正常运转之前，分散加载过程复制到SDRAM 中的数据都丢失了。所以现在我们需要在跳转到 main 函数之前就被调用，具体见 startup_stm32f40_41xxx.s文件。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210302211535.png" style="zoom:67%;">

<p>​    在执行__main 函数前先调用了我们自定义的FSMC_SRAM_Init函数，从而为分散加载代码准备好正常的硬件工作环境。</p>
<h3 id="2-2-sct-文件增加外部SDRAM空间对应的执行域"><a href="#2-2-sct-文件增加外部SDRAM空间对应的执行域" class="headerlink" title="2.2 sct 文件增加外部SDRAM空间对应的执行域"></a>2.2 sct 文件增加外部SDRAM空间对应的执行域</h3><p>​    修改sct文件，控制使得在C源文件中定义的全局变量都自动由链接器分配到外部SDRAM中。把“Options for Target-&gt;Linker-&gt;Use Memory Layout from Target Dialog”中的勾去掉。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210302212648.png" style="zoom:50%;">

<p>​    sct文件的格式如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210302213955.png" style="zoom:50%;">

<p>​    keil中自动生成的sct文件如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210302214356.png" style="zoom:50%;">

<p>​    上图<strong>执行域中</strong>包含了ER_IROM1及RW_IRAM1两个执行域，它们分别对应描述了STM32的内部 FLASH 及内部 SRAM 的基地址及空间大小。而它们内部的“输入节区描述”说明了哪些节区要存储到这些空间，链接器会根据它来处理编排这些节区。</p>
<p>​    修改之后的sct文件如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210303212905.png" style="zoom:60%;">

<ul>
<li>RW_ERAM1是我们配置的 SDRAM 执行域。该执行域的名字是可以随便取的，最重要的是它的基地址及空间大小，这两个值与我们实验板配置的 SDRAM 基地址及空间大小一致，所以该执行域会被映射到 SDRAM 的空间。在 RW_ERAM1 执行域内部，它使用“.ANY(+RW +ZI)”语句，选择了所有的 RW/ZI 类型的数据都分配到这个SDRAM 区域，所以我们在工程中的 C 文件定义全局变量时，它都会被分配到这个SDRAM 区域。</li>
<li>RW_IRAM1是STM32内部SRAM的执行域。我们在默认配置中增加了“*.o(STACK)语句。本来上面配置 SDRAM 执行域后已经达到使全局变量分配的目的，为何还要修改原内部 SRAM 的执行域呢？这是由于我们在__main 之前调用的 SystemInit 函数和 FSMC_SRAM_Init函数内部定义了一些局部变量，而函数内的局部变量是需要分配到“栈”空间(STACK)。所以在 FSMC_SRAM_Init函数执行之前，栈空间必须要被准备好，然而在 FSMC_SRAM_Init函数执行之前，SDRAM 芯片却并未正常工作，这样的矛盾导致栈空间不能被分配到 SDRAM。</li>
<li>虽然内部 SRAM 的执行域 RW_IRAM1 及 SDRAM 执行域 RW_ERAM1 中都使用“.ANY(+RW +ZI)”语句选择了所有 RW 及 ZI 属性的内容，但对于符合两个相同选择语句的内容，链接器会优先选择使用空间较大的执行域，即这种情况下只有当SDRAM 执行域的空间使用完了，RW/ZI 属性的内容才会被分配到内部 SRAM。</li>
<li>所以在大部分情况下，<strong>内部 SRAM 执行域中的“.ANY(+RW +ZI)”语句是不起作用的()，而栈节区(STACK)又属于 ZI-data 类，如果我们的内部 SRAM 执行域还是按原来的默认配置的话，栈节区会被分配到外部 SDRAM，导致出错</strong>。为了避免这个问题，我们把栈节区使用“*.o(STACK)”语句分配到内部 SRAM 的执行域。</li>
</ul>
<h2 id="3-变量分配测试"><a href="#3-变量分配测试" class="headerlink" title="3. 变量分配测试"></a>3. 变量分配测试</h2><p>​    这边的测试代码直接参考的野火的，如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//定义变量到 SDRAM</span></span><br><span class="line"><span class="keyword">uint32_t</span> testValue =<span class="number">7</span> ;</span><br><span class="line"><span class="comment">//定义变量到 SDRAM</span></span><br><span class="line"><span class="keyword">uint32_t</span> testValue2 =<span class="number">0</span>;</span><br><span class="line"><span class="comment">//定义数组到 SDRAM</span></span><br><span class="line"><span class="keyword">uint8_t</span> testGrup[<span class="number">100</span>] =&#123;<span class="number">0</span>&#125;;</span><br><span class="line"><span class="comment">//定义数组到 SDRAM</span></span><br><span class="line"><span class="keyword">uint8_t</span> testGrup2[<span class="number">100</span>] =&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125;;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123; </span><br><span class="line">	<span class="keyword">uint32_t</span> inerTestValue =<span class="number">10</span>;</span><br><span class="line">	delay_init(<span class="number">168</span>);		       </span><br><span class="line">	uart_init(<span class="number">115200</span>);</span><br><span class="line">  </span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;地址：0x%x,  值为：%d\r\n&quot;</span>,(<span class="keyword">uint32_t</span>)&amp;inerTestValue,inerTestValue);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;地址：0x%x,  值为：%d\r\n&quot;</span>,(<span class="keyword">uint32_t</span>)&amp;testValue,testValue);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;地址：0x%x,  值为：%d\r\n&quot;</span>,(<span class="keyword">uint32_t</span>)&amp;testValue2,testValue2);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;地址：0x%x,  值为：%d,%d,%d\r\n&quot;</span>,(<span class="keyword">uint32_t</span>)&amp;testGrup,testGrup[<span class="number">0</span>],testGrup[<span class="number">1</span>],testGrup[<span class="number">2</span>]);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;地址：0x%x,  值为：%d，%d,%d\r\n&quot;</span>,(<span class="keyword">uint32_t</span>)&amp;testGrup2,testGrup2[<span class="number">0</span>],testGrup2[<span class="number">1</span>],testGrup2[<span class="number">2</span>]);</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">uint32_t</span> * pointer = (<span class="keyword">uint32_t</span>*)<span class="built_in">malloc</span>(<span class="keyword">sizeof</span>(<span class="keyword">uint32_t</span>)*<span class="number">3</span>);</span><br><span class="line">	<span class="keyword">if</span>(pointer != <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		*(pointer)=<span class="number">1</span>;</span><br><span class="line">        *(++pointer)=<span class="number">2</span>;</span><br><span class="line">        *(++pointer)=<span class="number">3</span>; </span><br><span class="line"></span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;地址为：0x%x\r\n&quot;</span>,(<span class="keyword">uint32_t</span>)pointer); </span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;*(pointer--)=%d, \r\n&quot;</span>,*(pointer--));</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;*(pointer--)=%d, \r\n&quot;</span>,*(pointer--));</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;*(pointer)=%d, \r\n&quot;</span>,*(pointer));</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		GPIO_SetBits(GPIOF , GPIO_Pin_9);</span><br><span class="line">		delay_ms(<span class="number">1000</span>);</span><br><span class="line">		GPIO_ResetBits(GPIOF , GPIO_Pin_9);</span><br><span class="line">		delay_ms(<span class="number">1000</span>);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​    运行结果如下图：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210304093015.png" style="zoom:67%;">

<p>​    并查看工程的 map 文件观察变量的分配情况：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210304094021.png" style="zoom:80%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210304094531.png"></p>
<p>​    从 map 文件中，可看到 startup_stm32f40_41xxx.s 的 RW-data 及栈空间节区(STACK)都被分配到了 RW_IRAM1 区域，即 STM32 的内部 SRAM 空间中；而 main 文件中定义的 RW-data、ZI-data 以及堆空间节区(HEAP)都被分配到了 RW_ERAM1 区域，即我们扩展的SDRAM 空间中，看起来一切都与我们的 sct 文件配置一致了。(堆空间属于 ZI-data，由于没有像控制栈节区那样指定到内部 SRAM，所以它被默认分配到 SDRAM 空间了)</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/28/ARM%E4%B8%AD%E7%9A%84%E5%8A%A0%E8%BD%BD%E5%9F%9F%E5%92%8C%E8%BF%90%E8%A1%8C%E5%9F%9F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/28/ARM%E4%B8%AD%E7%9A%84%E5%8A%A0%E8%BD%BD%E5%9F%9F%E5%92%8C%E8%BF%90%E8%A1%8C%E5%9F%9F/" class="post-title-link" itemprop="url">ARM中加载域和运行域</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-28 20:38:11" itemprop="dateCreated datePublished" datetime="2021-02-28T20:38:11+08:00">2021-02-28</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/02/28/ARM%E4%B8%AD%E7%9A%84%E5%8A%A0%E8%BD%BD%E5%9F%9F%E5%92%8C%E8%BF%90%E8%A1%8C%E5%9F%9F/" class="post-meta-item leancloud_visitors" data-flag-title="ARM中加载域和运行域" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/28/ARM%E4%B8%AD%E7%9A%84%E5%8A%A0%E8%BD%BD%E5%9F%9F%E5%92%8C%E8%BF%90%E8%A1%8C%E5%9F%9F/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/28/ARM%E4%B8%AD%E7%9A%84%E5%8A%A0%E8%BD%BD%E5%9F%9F%E5%92%8C%E8%BF%90%E8%A1%8C%E5%9F%9F/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        下面的内容大多来自于野火及安富莱的教程，这边对他们表示由衷的感谢。一个程序包括只读的代码段和可读写的数据段。其中只读的代码段和常量被称作RO段(ReadOnly)；可读写的全局变量和静态变量被称作RW段(ReadWrite)；RW段中要被初始化为零的变量被称为ZI段(ZeroInit)。对于嵌入式系统而言，程序映象都是存储在Flash存储器等一些非易失性器件中的，<strong>而在运行时，程序中的RW段必须重新装载到可读写的RAM中</strong>。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image22.png" style="zoom:67%;">

<p>​        程序的<strong>加载时域</strong>就是指程序烧入Flash中的状态，<strong>运行时域</strong>是指程序执行时的状态。加载域就是映像文件被静态存放的工作区域，一般来说Flash里的 整个bin文件所在的地址空间就是加载域，当然程序一般都不会放在 Flash里执行，一般都会搬到SDRAM里运行工作，它们在被搬到SDRAM里工作所处的地址空间就是运行域。</p>
<h2 id="程序的加载与执行"><a href="#程序的加载与执行" class="headerlink" title="程序的加载与执行"></a>程序的加载与执行</h2><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210228202054.png" style="zoom:80%;">

<p>​    图中的左侧是应用程序的存储状态，右侧是运行状态，而上方是 RAM 存储器区域，下方是 ROM 存储器区域。   程序在存储状态时，RO 节(RO section)及 RW 节都被保存在 ROM 区**(因为初始值不为0，所以要事先保存在ROM中)**。当程序开始运行时，内核直接从 ROM 中读取代码，并且在执行主体代码前，会先执行一段加载代码，它把 RW 节数据从 ROM 复制到 RAM， 并且在 RAM 加入 ZI 节，ZI 节的数据都被初始化为0。加载完后 RAM 区准备完毕，正式开始执行主体程序。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/24/pyocd%E4%BD%BF%E7%94%A8%E7%AE%80%E4%BB%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/24/pyocd%E4%BD%BF%E7%94%A8%E7%AE%80%E4%BB%8B/" class="post-title-link" itemprop="url">pyocd使用简介</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-24 18:48:36" itemprop="dateCreated datePublished" datetime="2021-02-24T18:48:36+08:00">2021-02-24</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/02/24/pyocd%E4%BD%BF%E7%94%A8%E7%AE%80%E4%BB%8B/" class="post-meta-item leancloud_visitors" data-flag-title="pyocd使用简介" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/24/pyocd%E4%BD%BF%E7%94%A8%E7%AE%80%E4%BB%8B/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/24/pyocd%E4%BD%BF%E7%94%A8%E7%AE%80%E4%BB%8B/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="1-简介"><a href="#1-简介" class="headerlink" title="1. 简介"></a>1. 简介</h2><p>​    pyOCD 是 mbed 社区为 ARM Cortex-M 系列 MCU 所提供的编程和调试服务工具。它主要基于 CMSIS DAP 接口，能为不同的厂商提供了统一的调试接口。该工具能够与 DAPLink 仿真器完美配合，完成对Cortex-M系列MCU的编程和调试。</p>
<p>​    它是完全跨平台的，并支持Linux，macOS和Windows。它内置支持多达70种流行的MCU。另外，通过使用CMSIS-Pack，几乎支持市场上的所有Cortex-M设备。pyOCD还可以作为GDB Service配合GDB调试芯片，支持多种探针，比如：CMSIS-DAP v1(HID)、CMSIS-DAP v2(WinUSB)、SEGGER J-Link、ST-LINK v2和ST-LINK v3。pyOCD允许用户通过命令来：烧录、擦除、单步、停止、设置断点、全速运行、芯片上锁、读写外设寄存器、读写存储空间等操作。</p>
<p>​    这篇博文参考了网友在51黑电子论坛的文章，网址如下所示：<a target="_blank" rel="noopener" href="http://www.51hei.com/bbs/dpj-194723-1.html">http://www.51hei.com/bbs/dpj-194723-1.html</a> 在这对他表示感谢。</p>
<h2 id="2-安装"><a href="#2-安装" class="headerlink" title="2. 安装"></a>2. 安装</h2><p>​    pyOCD是一个python库，可用通过pip install pyocd就会自动安装pyOCD以及其依赖库。其中依赖库有：cmsis-pack-manger、intelhex、pyusb、pywinusb、pyelftools、pyyaml、six、pylink-square、prettytable、colorame和interbaltree。</p>
<p>​    安装完之后，查看pyocd的版本和帮助信息：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210223170018.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210223170314.png" style="zoom:67%;">

<p>​    通过subcommand知道，pyOCD的子命令有cmd、erase、flash、reset、gdbserver、gdb、json、list、pack和server。</p>
<h2 id="3-擦除和烧写指令使用"><a href="#3-擦除和烧写指令使用" class="headerlink" title="3. 擦除和烧写指令使用"></a>3. 擦除和烧写指令使用</h2><h3 id="3-1-擦除命令erase"><a href="#3-1-擦除命令erase" class="headerlink" title="3.1 擦除命令erase"></a>3.1 擦除命令erase</h3><p>​    擦除全部存储空间：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/删除整个芯片内容.png" style="zoom:67%;">

<h3 id="3-2-烧录命令flash"><a href="#3-2-烧录命令flash" class="headerlink" title="3.2 烧录命令flash"></a>3.2 烧录命令flash</h3><p>​    烧录支持三种格式的文件：hex、bin和elf，其中bin和elf不带地址信息，需要在参数指定烧录起始地址。</p>
<h4 id="3-2-1-不擦除芯片，单纯烧录hex"><a href="#3-2-1-不擦除芯片，单纯烧录hex" class="headerlink" title="3.2.1 不擦除芯片，单纯烧录hex"></a>3.2.1 不擦除芯片，单纯烧录hex</h4><p>​    烧录后运行也成功了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/烧写.png" style="zoom:67%;">

<h4 id="3-2-2-先擦除，再烧录hex"><a href="#3-2-2-先擦除，再烧录hex" class="headerlink" title="3.2.2 先擦除，再烧录hex"></a>3.2.2 先擦除，再烧录hex</h4><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20210224092707.png"></p>
<h4 id="3-2-3-先擦除，再烧录bin，指定起始地址为0x8000000"><a href="#3-2-3-先擦除，再烧录bin，指定起始地址为0x8000000" class="headerlink" title="3.2.3 先擦除，再烧录bin，指定起始地址为0x8000000"></a>3.2.3 先擦除，再烧录bin，指定起始地址为0x8000000</h4><p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20210224184357.png"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/22/PyQt5%E4%B8%AD%E4%BD%BF%E7%94%A8pyqtgraph%E7%9A%84PlotWidget%E7%94%BB%E5%9B%BE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/22/PyQt5%E4%B8%AD%E4%BD%BF%E7%94%A8pyqtgraph%E7%9A%84PlotWidget%E7%94%BB%E5%9B%BE/" class="post-title-link" itemprop="url">PyQt5中使用pyqtgraph的PlotWidget画图</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-22 14:40:46" itemprop="dateCreated datePublished" datetime="2021-02-22T14:40:46+08:00">2021-02-22</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/QT/" itemprop="url" rel="index"><span itemprop="name">QT</span></a>
                </span>
            </span>

          
            <span id="/2021/02/22/PyQt5%E4%B8%AD%E4%BD%BF%E7%94%A8pyqtgraph%E7%9A%84PlotWidget%E7%94%BB%E5%9B%BE/" class="post-meta-item leancloud_visitors" data-flag-title="PyQt5中使用pyqtgraph的PlotWidget画图" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/22/PyQt5%E4%B8%AD%E4%BD%BF%E7%94%A8pyqtgraph%E7%9A%84PlotWidget%E7%94%BB%E5%9B%BE/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/22/PyQt5%E4%B8%AD%E4%BD%BF%E7%94%A8pyqtgraph%E7%9A%84PlotWidget%E7%94%BB%E5%9B%BE/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="1-前言"><a href="#1-前言" class="headerlink" title="1. 前言"></a>1. 前言</h2><p>​    PlotWidget控件在pyqtgraph中有，可以看到有些代码中开始部分是这么写的：from pyqtgraph import PlotWidget。这里主要演示如何使用QtDesigner配合PlotWidget作图。</p>
<h2 id="2-QtDesigner-新建布局"><a href="#2-QtDesigner-新建布局" class="headerlink" title="2. QtDesigner 新建布局"></a>2. QtDesigner 新建布局</h2><p>​    窗口中插入Graphics view控件：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210222142304.png" style="zoom:67%;">

<p>​    将该控件提升至 PlotWidget，右键单击添加的 Graphics View 控件，选择 提升为…</p>
<p>​    按图中基类名称选择 QGraphicsView，提升的类名称填写 PlotWidget 以及最终的 头文件 输入 pyqtgraph, 点击右侧的 添加：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210222142756.png" style="zoom:67%;">

<p>​    添加完成，选择该项，点击右下角提升：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210222134702.png" style="zoom:67%;">

<p>​    现在我们就完成了 PlotWidget 控件的添加，接下来可以在属性框中修改控件名称：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20210222143245.png" style="zoom:67%;">

<h2 id="3-ui-文件转-py-代码文件"><a href="#3-ui-文件转-py-代码文件" class="headerlink" title="3. ui 文件转 py 代码文件"></a>3. ui 文件转 py 代码文件</h2><p>​    将 ui 文件保存，并通过 PyQt5.uic.pyuic 将 ui 文件转化为 py 代码文件，不要编辑改动该文件。</p>
<h2 id="4-主程序导入布局并添加作图内容"><a href="#4-主程序导入布局并添加作图内容" class="headerlink" title="4. 主程序导入布局并添加作图内容"></a>4. 主程序导入布局并添加作图内容</h2><p>​    此时我们有了控制布局的 untitled.py ，接下来我们新建个导入布局、添加功能的 py 主程序代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">import</span> multiprocessing</span><br><span class="line"><span class="keyword">from</span> multiprocessing <span class="keyword">import</span> Queue</span><br><span class="line"><span class="keyword">from</span> parameter <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> rt_rxUSB <span class="keyword">import</span> rxUSB_process</span><br><span class="line"><span class="keyword">from</span> rt_deUSB <span class="keyword">import</span> deUSB_process</span><br><span class="line"><span class="keyword">from</span> pyqtgraph.Qt <span class="keyword">import</span> QtGui, QtCore</span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line"><span class="keyword">import</span> untitled <span class="keyword">as</span> untitled_ui</span><br><span class="line"></span><br><span class="line">Range_energy = np.zeros(fft_point)</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&#x27;__main__&#x27;</span>:</span><br><span class="line">    multiprocessing.freeze_support()</span><br><span class="line"></span><br><span class="line">    app = QtGui.QApplication([])</span><br><span class="line">    win = QtGui.QMainWindow()</span><br><span class="line">    ui = untitled_ui.Ui_MainWindow()</span><br><span class="line">    ui.setupUi(win)</span><br><span class="line">    win.show()</span><br><span class="line">    curve1 = ui.my_plotWidget.plot(Range_energy, pen=<span class="string">&#x27;g&#x27;</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 创建队列</span></span><br><span class="line">    rxQ = Queue()</span><br><span class="line">    deQ = Queue()</span><br><span class="line"></span><br><span class="line">    de_thread = deUSB_process(rxQ, deQ)</span><br><span class="line">    de_thread.start()</span><br><span class="line"></span><br><span class="line">    rx_thread = rxUSB_process(<span class="string">&#x27;AUTO&#x27;</span>, rxQ)</span><br><span class="line">    rx_thread.start()</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">update</span>():</span></span><br><span class="line">        <span class="keyword">if</span> <span class="keyword">not</span> deQ.empty():</span><br><span class="line">            eng = deQ.get_nowait()</span><br><span class="line">            Range_energy = eng</span><br><span class="line">            curve1.setData(Range_energy)</span><br><span class="line">            time.sleep(<span class="number">0.2</span>)</span><br><span class="line">            Range_energy.fill(<span class="number">0</span>)</span><br><span class="line"></span><br><span class="line">    timer = QtCore.QTimer()</span><br><span class="line">    timer.timeout.connect(update)</span><br><span class="line">    timer.start(<span class="number">10</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> (sys.flags.interactive != <span class="number">1</span>) <span class="keyword">or</span> <span class="keyword">not</span> <span class="built_in">hasattr</span>(QtCore, <span class="string">&#x27;PYQT_VERSION&#x27;</span>):</span><br><span class="line">        QtGui.QApplication.instance().exec_()</span><br><span class="line">    sys.exit()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/20/%E4%BC%A0%E6%84%9F%E5%99%A8%E6%8D%A2%E7%94%B5%E6%BA%90%E5%90%8E%E6%95%B0%E6%8D%AE%E8%AF%BB%E4%B8%8D%E5%AF%B9/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/20/%E4%BC%A0%E6%84%9F%E5%99%A8%E6%8D%A2%E7%94%B5%E6%BA%90%E5%90%8E%E6%95%B0%E6%8D%AE%E8%AF%BB%E4%B8%8D%E5%AF%B9/" class="post-title-link" itemprop="url">传感器换电源后数据读不对</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-20 20:07:08" itemprop="dateCreated datePublished" datetime="2021-02-20T20:07:08+08:00">2021-02-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2021/02/20/%E4%BC%A0%E6%84%9F%E5%99%A8%E6%8D%A2%E7%94%B5%E6%BA%90%E5%90%8E%E6%95%B0%E6%8D%AE%E8%AF%BB%E4%B8%8D%E5%AF%B9/" class="post-meta-item leancloud_visitors" data-flag-title="传感器换电源后数据读不对" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/20/%E4%BC%A0%E6%84%9F%E5%99%A8%E6%8D%A2%E7%94%B5%E6%BA%90%E5%90%8E%E6%95%B0%E6%8D%AE%E8%AF%BB%E4%B8%8D%E5%AF%B9/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/20/%E4%BC%A0%E6%84%9F%E5%99%A8%E6%8D%A2%E7%94%B5%E6%BA%90%E5%90%8E%E6%95%B0%E6%8D%AE%E8%AF%BB%E4%B8%8D%E5%AF%B9/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    现象：有一个气体传感器，单独供电数据读取正确。当把他接到自己做的一块板子上时，数据一直不对。板子的电路图如下所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/0.jpg" style="zoom:40%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/2.jpg" style="zoom:40%;">

<p>​    外部5V电源从J12那边供的，传感器是接到J13的。出错的关键是接了一个D25，本意是为了防止电源接反。但是一旦接了传感器，就有了电流，<strong>而D25这个二极管选的恰恰压降比较大，分压比较大，到传感器那边基本只剩下4V了，所以数据一直不对</strong>。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/20/stm32%E6%97%A0%E6%B3%95%E8%AF%BBmma8452%E7%9A%84ID/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/20/stm32%E6%97%A0%E6%B3%95%E8%AF%BBmma8452%E7%9A%84ID/" class="post-title-link" itemprop="url">stm32无法读mma8452的ID</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-20 18:56:57" itemprop="dateCreated datePublished" datetime="2021-02-20T18:56:57+08:00">2021-02-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2021/02/20/stm32%E6%97%A0%E6%B3%95%E8%AF%BBmma8452%E7%9A%84ID/" class="post-meta-item leancloud_visitors" data-flag-title="stm32无法读mma8452的ID" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/20/stm32%E6%97%A0%E6%B3%95%E8%AF%BBmma8452%E7%9A%84ID/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/20/stm32%E6%97%A0%E6%B3%95%E8%AF%BBmma8452%E7%9A%84ID/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    因为stm32使用HAL库的HAL_I2C_Master_Transmit_IT()函数，在发送完设备地址和寄存器地址后，又多发送了一个Stop信号，如下面示波器抓取的图：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Capture.JPG" style="zoom:67%;">

<p>​    解决方法是换一个库函数来读取：HAL_I2C_Mem_Read。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/20/Jetson%20TX2%E4%B8%8A%E6%97%A5%E5%BF%97%E6%BB%A1%E9%80%A0%E6%88%90%E7%A1%AC%E7%9B%98%E6%8C%A4%E7%88%86%E9%97%AE%E9%A2%98/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/20/Jetson%20TX2%E4%B8%8A%E6%97%A5%E5%BF%97%E6%BB%A1%E9%80%A0%E6%88%90%E7%A1%AC%E7%9B%98%E6%8C%A4%E7%88%86%E9%97%AE%E9%A2%98/" class="post-title-link" itemprop="url">Jetson TX2上日志满造成硬盘挤爆问题</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-20 18:07:42" itemprop="dateCreated datePublished" datetime="2021-02-20T18:07:42+08:00">2021-02-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Ubuntu/" itemprop="url" rel="index"><span itemprop="name">Ubuntu</span></a>
                </span>
            </span>

          
            <span id="/2021/02/20/Jetson%20TX2%E4%B8%8A%E6%97%A5%E5%BF%97%E6%BB%A1%E9%80%A0%E6%88%90%E7%A1%AC%E7%9B%98%E6%8C%A4%E7%88%86%E9%97%AE%E9%A2%98/" class="post-meta-item leancloud_visitors" data-flag-title="Jetson TX2上日志满造成硬盘挤爆问题" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/20/Jetson%20TX2%E4%B8%8A%E6%97%A5%E5%BF%97%E6%BB%A1%E9%80%A0%E6%88%90%E7%A1%AC%E7%9B%98%E6%8C%A4%E7%88%86%E9%97%AE%E9%A2%98/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/20/Jetson%20TX2%E4%B8%8A%E6%97%A5%E5%BF%97%E6%BB%A1%E9%80%A0%E6%88%90%E7%A1%AC%E7%9B%98%E6%8C%A4%E7%88%86%E9%97%AE%E9%A2%98/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    Jetson TX2上发现log占满磁盘，检查下来发现是由于ubuntu自带的rsyslogd服务引起。</p>
<p>​    rsyslogd存储的log需要logrorate定时任务进行清理。</p>
<p>​    所以，需要修改 /etc/logrotate.d/rsyslog 配置文件，修改内容如下：/var/log/syslog</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">​    rotate <span class="number">7</span></span><br><span class="line">​    maxsize <span class="number">500</span>M</span><br><span class="line">​    daily</span><br><span class="line">​    missingok</span><br><span class="line">​    notifempty</span><br><span class="line">​    delaycompress</span><br><span class="line">​    compress</span><br><span class="line">​    postrotate</span><br><span class="line">​    invoke-rc.d rsyslog rotate &gt; /dev/null</span><br><span class="line">​    endscript</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在原文件中新增<strong>maxsize 500M</strong></p>
<p>修改完之后执行命令：sudo /usr/sbin/logrotate -f /etc/logrotate.conf</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/17/%E8%9A%82%E8%9A%81%E6%A3%AE%E6%9E%97%E8%87%AA%E5%8A%A8%E6%94%B6%E8%83%BD%E9%87%8F-%E8%BD%AC%E8%BD%BD/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/17/%E8%9A%82%E8%9A%81%E6%A3%AE%E6%9E%97%E8%87%AA%E5%8A%A8%E6%94%B6%E8%83%BD%E9%87%8F-%E8%BD%AC%E8%BD%BD/" class="post-title-link" itemprop="url">蚂蚁森林自动收能量-转载</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-17 12:00:17" itemprop="dateCreated datePublished" datetime="2021-02-17T12:00:17+08:00">2021-02-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2021/02/17/%E8%9A%82%E8%9A%81%E6%A3%AE%E6%9E%97%E8%87%AA%E5%8A%A8%E6%94%B6%E8%83%BD%E9%87%8F-%E8%BD%AC%E8%BD%BD/" class="post-meta-item leancloud_visitors" data-flag-title="蚂蚁森林自动收能量-转载" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/17/%E8%9A%82%E8%9A%81%E6%A3%AE%E6%9E%97%E8%87%AA%E5%8A%A8%E6%94%B6%E8%83%BD%E9%87%8F-%E8%BD%AC%E8%BD%BD/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/17/%E8%9A%82%E8%9A%81%E6%A3%AE%E6%9E%97%E8%87%AA%E5%8A%A8%E6%94%B6%E8%83%BD%E9%87%8F-%E8%BD%AC%E8%BD%BD/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="1-简介"><a href="#1-简介" class="headerlink" title="1. 简介"></a>1. 简介</h2><p>​    这篇博文是来自网上其他网友的，<a target="_blank" rel="noopener" href="https://blog.csdn.net/csdnsevenn">https://blog.csdn.net/csdnsevenn</a> ，我这边按照他的教程做了一遍，非常感谢，确实实现了蚂蚁森林能量的自动收取。</p>
<p>​    接下来介绍下原理和实现方式，首先如果让你手动去收能量的话，你是什么流程？</p>
<ol>
<li><p>打开支付宝；</p>
</li>
<li><p>打开蚂蚁森林；</p>
</li>
<li><p>先收取自己的能量；</p>
</li>
<li><p>跳到下一个有能量的人那边；</p>
</li>
<li><p>收取 ta 的能量</p>
</li>
<li><p>重复 4 和 5，直到没有能量可以“偷”</p>
<p>按照网友的介绍，借助 Uiautomator2，这些都可以自动化。UiAutomator 是 Google 提供的用来做安卓自动化测试的一个 Java 库，可以获取屏幕上任意一个 APP 的任意一个控件属性，并对其进行任意操作。Uiautomator2 是在 Uiautomator 之上的 Python 的接口封装，简单来说 Uiautomator2 可以看到手机当前屏幕上有哪些控件，其坐标，并且还可以模拟点击。</p>
</li>
</ol>
<h2 id="2-具体实现"><a href="#2-具体实现" class="headerlink" title="2. 具体实现"></a>2. 具体实现</h2><h3 id="2-1-Uiautomator2的安装"><a href="#2-1-Uiautomator2的安装" class="headerlink" title="2.1 Uiautomator2的安装"></a>2.1 Uiautomator2的安装</h3><p>​    pip install <em>–upgrade –pre uiautomator2</em></p>
<p>​    使用的话这里有几个坑，手机接入电脑前首先需要开启开发者模式，并开启USB调试，这样才能保证uiautomator2有足够的权限操作你的手机。第一次使用过uiautomator2后，它会在你手机上安装ATX这个应用，打开这个应用你就可以之后通过无线的方式操作你的手机了。</p>
<h3 id="2-2-如何打开支付宝进入蚂蚁森林"><a href="#2-2-如何打开支付宝进入蚂蚁森林" class="headerlink" title="2.2 如何打开支付宝进入蚂蚁森林"></a>2.2 如何打开支付宝进入蚂蚁森林</h3><p>​    Uiautomator2可以直接通过应用包名调起应用d.app_start(“com.eg.android.AlipayGphone”)，啥？你不知道支付宝的包名？你可以安装Uiautomators2后用其命令行查看支付宝的包名，具体可以查阅其文档。</p>
<p>​    如何进入蚂蚁森林？Uiautomators2提供了直接点击屏幕某个文字的位置，d(text=”蚂蚁森林”).click()。所以建议你把蚂蚁森林放的支付宝首页，这样打开支付宝后就可以直接定位到蚂蚁森林的位置了。</p>
<p>​    目前定位到具体能量的位置，所以最简单的方式就是把所有能量可能出现的位置都扫一遍(如上图红框)，然后点击找能量按钮跳到下一个人那继续扫荡。</p>
<h3 id="2-3-如何停止"><a href="#2-3-如何停止" class="headerlink" title="2.3 如何停止"></a>2.3 如何停止</h3><p>​    怎么停下来是个大问题，因为上面的逻辑都是模拟点击，如果不在合适的时机停下来，鬼知道它会按出什么东西。通过几次观察，我发现没有能量偷之后，支付宝会跳到下面这个页面上，这里只需要检查下”返回我的森林”按钮是否存在即可。</p>
<h2 id="3-代码实现"><a href="#3-代码实现" class="headerlink" title="3. 代码实现"></a>3. 代码实现</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> uiautomator2 <span class="keyword">as</span> u2</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">import</span> random</span><br><span class="line"><span class="comment"># d = u2.connect()  # 有线连接，手机需要插电脑上 </span></span><br><span class="line">d = u2.connect(<span class="string">&quot;192.168.0.108&quot;</span>) <span class="comment">#通过无线连接，电脑和手机需要在同一个局域网内，并且需要先用有线的方式做过初始化</span></span><br><span class="line"> </span><br><span class="line"><span class="comment"># d.app_stop(&quot;com.eg.android.AlipayGphone&quot;) </span></span><br><span class="line">print(<span class="string">&quot;打开支付宝&quot;</span>)</span><br><span class="line">d.app_start(<span class="string">&quot;com.eg.android.AlipayGphone&quot;</span>)</span><br><span class="line">time.sleep(<span class="number">2</span>) <span class="comment">## 休眠2s等待支付宝完全启动</span></span><br><span class="line"> </span><br><span class="line">print(<span class="string">&quot;打开蚂蚁森林，等待5s……&quot;</span>)</span><br><span class="line">d(text=<span class="string">&quot;蚂蚁森林&quot;</span>).click()</span><br><span class="line">time.sleep(<span class="number">5</span>) <span class="comment">## 手机比较卡，进入蚂蚁森林后还需要几秒钟才能完全加载完   </span></span><br><span class="line"> </span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">collectEnergy</span>(<span class="params">cnt</span>):</span></span><br><span class="line">    print(<span class="string">&quot;开始第%d次偷能量！&quot;</span> % cnt)</span><br><span class="line">    <span class="comment"># 开始扫描点击有能力出现的区域  </span></span><br><span class="line">    <span class="keyword">for</span> x <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">150</span>,<span class="number">1000</span>,<span class="number">150</span>):</span><br><span class="line">        <span class="keyword">for</span> y <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">600</span>,<span class="number">900</span>,<span class="number">150</span>):</span><br><span class="line">            d.long_click(x + random.randint(<span class="number">10</span>,<span class="number">20</span>), y + random.randint(<span class="number">10</span>,<span class="number">20</span>), <span class="number">0.1</span>)</span><br><span class="line">            time.sleep(<span class="number">0.01</span>)</span><br><span class="line">            <span class="keyword">if</span> cnt != <span class="number">1</span>:</span><br><span class="line">                d.click(<span class="number">536</span>,<span class="number">1816</span>)</span><br><span class="line"> </span><br><span class="line">cnt = <span class="number">1</span></span><br><span class="line"><span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">    collectEnergy(cnt)</span><br><span class="line">    a = d.xpath(<span class="string">&quot;//*[@resource-id=&#x27;J_tree_dialog_wrap&#x27;]&quot;</span>).get().bounds </span><br><span class="line">    d.click(<span class="number">1000</span>, a[<span class="number">3</span>]-<span class="number">80</span>) <span class="comment"># 找能量按钮的坐标 </span></span><br><span class="line">    <span class="comment">## 如果页面出现了“返回我的森林”说明已经没有能量可偷了，结束</span></span><br><span class="line">    <span class="keyword">if</span> d.xpath(<span class="string">&#x27;//*[@text=&quot;返回我的森林&quot;]&#x27;</span>).click_exists(timeout=<span class="number">2.0</span>):</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    cnt += <span class="number">1</span></span><br><span class="line">print(<span class="string">&quot;###结束###&quot;</span>)</span><br><span class="line"><span class="comment"># d.app_stop(&quot;com.eg.android.AlipayGphone&quot;) # 退出支付宝</span></span><br></pre></td></tr></table></figure>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/09/USB%E4%B9%8B%E6%8E%A7%E5%88%B6%E4%BC%A0%E8%BE%93%E5%8C%85/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/09/USB%E4%B9%8B%E6%8E%A7%E5%88%B6%E4%BC%A0%E8%BE%93%E5%8C%85/" class="post-title-link" itemprop="url">USB之控制传输包</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-09 18:54:20" itemprop="dateCreated datePublished" datetime="2021-02-09T18:54:20+08:00">2021-02-09</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/USB/" itemprop="url" rel="index"><span itemprop="name">USB</span></a>
                </span>
            </span>

          
            <span id="/2021/02/09/USB%E4%B9%8B%E6%8E%A7%E5%88%B6%E4%BC%A0%E8%BE%93%E5%8C%85/" class="post-meta-item leancloud_visitors" data-flag-title="USB之控制传输包" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/09/USB%E4%B9%8B%E6%8E%A7%E5%88%B6%E4%BC%A0%E8%BE%93%E5%8C%85/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/09/USB%E4%B9%8B%E6%8E%A7%E5%88%B6%E4%BC%A0%E8%BE%93%E5%8C%85/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="1-控制传输"><a href="#1-控制传输" class="headerlink" title="1. 控制传输"></a>1. 控制传输</h2><p>​    控制传输是USB的四种传输类型中最重要的一种，因此这边单独拿出来讲解。内容基本都来自于CSDN上博主：<a target="_blank" rel="noopener" href="https://hellocode.blog.csdn.net/%EF%BC%8C%E5%9C%A8%E8%BF%99%E8%BE%B9%E9%9D%9E%E5%B8%B8%E6%84%9F%E8%B0%A2%E4%BB%96%E3%80%82">https://hellocode.blog.csdn.net/，在这边非常感谢他。</a></p>
<p>​    控制传输有三个过程：建立过程(需要1个setup事务)，</p>
<p>​                                          数据过程(需要0个或者多个in/out事务)，</p>
<p>​                                          状态过程(需要1个in/out事务)。</p>
<h2 id="2-建立过程的包"><a href="#2-建立过程的包" class="headerlink" title="2. 建立过程的包"></a>2. 建立过程的包</h2><p>​    建立过程由1个setup事务组成，而事务由令牌包Token packet、数据包Data packet、握手包Handshack packet组成(注意一个例外：同步传输是只有2个包，没有握手包)。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210125212815445.png"></p>
<h3 id="2-1-setup事务的令牌包"><a href="#2-1-setup事务的令牌包" class="headerlink" title="2.1 setup事务的令牌包"></a>2.1 setup事务的令牌包</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210125213211378.png" style="zoom:67%;">

<p>​    </p>
<p>​    从上图可以知道SETUP PID为1101B，则补码校验为0010，在链路上传输先低后高则为,1011_0100（0xB4）,下图为SETUP包的链路波形图。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210125214056780.png" style="zoom:80%;">

<h3 id="2-2-setup事务的数据包"><a href="#2-2-setup事务的数据包" class="headerlink" title="2.2 setup事务的数据包"></a>2.2 setup事务的数据包</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210125214802687.png" style="zoom:70%;">

<p>​    setup事务的数据包就是DATA0数据包里面的8个字节的数据Data，包含主机的很多设置信息（数据传输方向、数据类型、目标类型、附加数据、数据阶段传输的数据长度等等。<strong>这8字节的数据包是主机用来发送建立过程中的请求命令的，而这些请求命令是主机配置USB设备的关键</strong>。这里就来详细分析这8字节请求命令的结构和内容。</p>
<p>​    <strong>说明：</strong>这些USB设备请求命令都是主机通过缺省的控制管道利用控制传输来发送的。在USB1.1中，这样的命令共有11个，它们的大小多是8字节，都具有相同的数据格式。</p>
<table>
<thead>
<tr>
<th><strong>偏移量</strong></th>
<th><strong>请求</strong></th>
<th><strong>大小</strong></th>
<th><strong>意义</strong></th>
</tr>
</thead>
<tbody><tr>
<td>0</td>
<td>bmRequestType</td>
<td>1</td>
<td>请求命令类型。每一位代表一定的意义。<br>D7，选择数据传输方向，0 = 主机到设备（即输出OUT），1 = 设备到主机（即输入IN）。<br>D6D5，命令的类型<br>00 = 标准请求命令<br>01 = 类请求命令<br>10 = 用户定义的请求命令<br>11 = 保留<br>D4-D0，命令的接收者类型<br>00000 = 接收者为设备<br>00001 = 接收者为接口<br>00010 = 接收者为端点<br>00011 = 其他接收者<br>其他值保留。</td>
</tr>
<tr>
<td>1</td>
<td>bRequest</td>
<td>1</td>
<td>请求命令代码。<br>在标准的USB请求命令中，USB为每一个命令定义了编号，即为此段的值。<br>0 = GET_STATUS<br>1 = CLEAR_FEATURE<br>3 = SET_FEATURE<br>5 = SET_ADDRESS<br>6 = GET_DESCRIPTOR<br>7 = SET_DESCRIPTOR<br>8 = GET_CONFIGURATION<br>9 = SET_CONFIGURATION<br>10 = GET_INTERFACE<br>11 = SET_INTERFACE<br>12 = SYNCH_FRAME</td>
</tr>
<tr>
<td>2</td>
<td>wValue</td>
<td>2</td>
<td>命令信息。<br>每一种请求命令都可以自行来定义这个字段的内容。</td>
</tr>
<tr>
<td>4</td>
<td>wIndex</td>
<td>2</td>
<td>索引信息。<br> 命令也可以自定义该字段的内容，但一般该字段的内容为索引值或偏移值。 当传输一个端点的索引值时： <br>第一字节 D7，方向位，0 = 输出OUT端点，1 = 输入IN端点 <br>D3-D0，端点号 <br>其他位即第二字节为保留值0。<br><br>当传输一个接口的索引值时：<br>第一字节<br>D7~D0，接口编号（可以在接口描述符中得到）<br>第二字节为保留值0。</td>
</tr>
<tr>
<td>6</td>
<td>wLength</td>
<td>2</td>
<td>传输的数据大小。<br>该字段表示在控制传输的“可选数据步骤”中要传输的数据大小。<br>当数据发送方向是主机到设备时，字段值便是实际的数据大小；<br>当数据发送方向是设备到主机时，字段值是设备能够发送的最大数据包的大小<br>当然，设备实际发送的数据可以比wLength的值小。</td>
</tr>
</tbody></table>
<h3 id="2-3-setup事务的握手包"><a href="#2-3-setup事务的握手包" class="headerlink" title="2.3 setup事务的握手包"></a>2.3 setup事务的握手包</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/2021012522323414.png" style="zoom:55%;">

<h2 id="3-数据过程的包"><a href="#3-数据过程的包" class="headerlink" title="3. 数据过程的包"></a>3. 数据过程的包</h2><p>​    数据过程由0个或者多个in/out事务组成。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210125224201877.png"></p>
<p>​    上图这个例子是第一阶段指定读（传输方向为设备到主机），则数据过程会由连续的多个IN事务组成，上图中第二阶段就是指的数据过程的意思，图中数据过程有3个in事务。</p>
<h2 id="4-状态过程的包"><a href="#4-状态过程的包" class="headerlink" title="4.状态过程的包"></a>4.状态过程的包</h2><p>​    状态过程由1个OUT/IN事务组成。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210125230739431.png" style="zoom:80%;">

<p>​    如果图中第二阶段指定数据传输方向为设备到主机，则主机接收完毕数据后，主机请求一个OUT事务告诉设备数据的接收状态。</p>
<p>​    如果第二阶段指定数据传输方向为主机到设备，则主机发送完毕数据后，<strong>主机请求一个IN事务</strong>请求设备数据接收状态，如下图所示。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/20210125231342919.png" style="zoom:80%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/02/08/PyCharm+QTDesigner+PyUIC%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2021/02/08/PyCharm+QTDesigner+PyUIC%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/" class="post-title-link" itemprop="url">PyCharm+Qt Designer+PyUIC使用教程</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-02-08 14:53:43" itemprop="dateCreated datePublished" datetime="2021-02-08T14:53:43+08:00">2021-02-08</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/QT/" itemprop="url" rel="index"><span itemprop="name">QT</span></a>
                </span>
            </span>

          
            <span id="/2021/02/08/PyCharm+QTDesigner+PyUIC%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/" class="post-meta-item leancloud_visitors" data-flag-title="PyCharm+Qt Designer+PyUIC使用教程" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/02/08/PyCharm+QTDesigner+PyUIC%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/02/08/PyCharm+QTDesigner+PyUIC%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​    这里我们演示这么一个简单的程序：程序主界面上有一个按钮和一个编缉框，点击按钮就在编缉框中显示“你点击了按钮”。</p>
<h2 id="一、使用QT-Desinger设计程序主界面"><a href="#一、使用QT-Desinger设计程序主界面" class="headerlink" title="一、使用QT Desinger设计程序主界面"></a>一、使用QT Desinger设计程序主界面</h2><h3 id="1-1-设计界面"><a href="#1-1-设计界面" class="headerlink" title="1.1 设计界面"></a>1.1 设计界面</h3><p>​    在PyCharm中创建一个项目，然后点击“Tools”–“External Tools”–“QTDesinger”打开QT Desinger</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image4.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image5.png" style="zoom:50%;">

<p>​    然后向Form中拖入一个“Push Button”和一个“Text Edit”：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image5.png" style="zoom:67%;">

<h3 id="1-2-指定点击事件及其响应函数"><a href="#1-2-指定点击事件及其响应函数" class="headerlink" title="1.2 指定点击事件及其响应函数"></a>1.2 指定点击事件及其响应函数</h3><p>​    在工具栏点击信号-槽编缉按钮—-光标移动到“PushButton”按钮上—-鼠标左键点击“PushButton”不要松开–拖动光标到Form的任一位置后再松开鼠标左键：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image6.png" style="zoom:67%;">

<p>​    经过上边的操作就出现了如下界面，“pushButton”侧选中“click()”，“Form”侧点击“Edit”：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image7.png" style="zoom:50%;">

<p>​    在上边“Slots”点击绿色“+”按钮，指定click事件的响应函数，名称随意定比如我这里命名为“pushButton_click()”（我们这里只是指定事件与响应函数的关联关系，函数是还没实现的，后边我们自行实现）</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image8.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image9.png" style="zoom:50%;">

<p>​    这样界面设计和事件关联就完成了，我们下来选择保存，将文件保存到项目的根目录下：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image10.png" style="zoom:50%;">



<h2 id="二、使用PyUIC将文件转成python代码"><a href="#二、使用PyUIC将文件转成python代码" class="headerlink" title="二、使用PyUIC将文件转成python代码"></a><strong>二、使用PyUIC将文件转成python代码</strong></h2><p>​    关闭QT Designer回到PyCharm，查看项目，可以看到只有刚才保存的PyQT_Form.ui文件而且该文件在PyCharm是打不开的我们需要将这个文件转成.py代码才能使用选中“PyQT_Form”，在其上点击鼠标右键，到“External Tools”中点击“PyUIC”完后再看项目文件，就可以看到多了一个“PyQT_Form.py”，双击查看其内容如下：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/Image12.png" style="zoom:67%;">

<h2 id="三、实现程序"><a href="#三、实现程序" class="headerlink" title="三、实现程序"></a><strong>三、实现程序</strong></h2><p>​    应该来说我们只要在上边的“PyQT_Form.py”中，将需要的包导入—添加pushButton_click()函数实现代码—-实例化Ui_Form类，实现这三步程序应该就差不多了但是PyQT_Form.py是PyUIC文件按照“PyQT_Form.ui”生成的，如果我们需要去调整PyQT_Form.ui（比如调整按钮位置调整文本框大小，后续调整界面在实际编程中基本是必然需求）。</p>
<p>​    调整完后重新生成PyQT_Form.py时，PyUIC可不会管当前我们已经在PyQT_Form.py中写了什么代码，旧PyQT_Form.py会直接被新PyQT_Form.py覆盖也就是说，所有逻辑代码我们都不应当写入PyQT_Form.py文件（或者叫不要动PyQT_Form.py文件），我们新建一个文件在里边创建一个子类（MyPyQT_Form）继承PyQT_Form.py中的Ui_Form。</p>
<h3 id="3-1-实现代码"><a href="#3-1-实现代码" class="headerlink" title="3.1 实现代码"></a><strong>3.1 实现代码</strong></h3><p>​    在项目中新建一个.py文件，写入如下代码</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> sysfrom PyQt5 </span><br><span class="line"><span class="keyword">import</span> QtWidgets</span><br><span class="line">from PyQT_Form <span class="keyword">import</span> Ui_Form</span><br><span class="line"></span><br><span class="line"><span class="function">class <span class="title">MyPyQT_Form</span><span class="params">(QtWidgets.QWidget,Ui_Form)</span>:    </span></span><br><span class="line"><span class="function">	def __<span class="title">init__</span><span class="params">(self)</span>:        </span></span><br><span class="line"><span class="function">		<span class="title">super</span><span class="params">(MyPyQT_Form,self)</span>.__<span class="title">init__</span><span class="params">()</span>        </span></span><br><span class="line"><span class="function">        self.<span class="title">setupUi</span><span class="params">(self)</span>    </span></span><br><span class="line"><span class="function">    </span></span><br><span class="line">    #实现pushButton_click()函数，textEdit是我们放上去的文本框的id    </span><br><span class="line">    <span class="function">def <span class="title">pushButton_click</span><span class="params">(self)</span>:        </span></span><br><span class="line"><span class="function">		self.textEdit.<span class="title">setText</span><span class="params">(<span class="string">&quot;你点击了按钮&quot;</span>)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line">if __name__ == &#x27;__main__&#x27;:    </span><br><span class="line">	app = QtWidgets.QApplication(sys.argv)    </span><br><span class="line">    my_pyqt_form = MyPyQT_Form()    </span><br><span class="line">    my_pyqt_form.show()    </span><br><span class="line">    sys.<span class="built_in">exit</span>(app.exec_())</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/26/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/26/">26</a><span class="page-number current">27</span><a class="page-number" href="/page/28/">28</a><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/28/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
